home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts44-07
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Classes over network?
- Date: Fri, 02 Feb 96 19:30:53 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4etoff$7s1@sam.inforamp.net>
- References: <4erliv$sva@lastactionhero.rs.itd.umich.edu>
- NNTP-Posting-Host: ts44-07.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4erliv$sva@lastactionhero.rs.itd.umich.edu>,
- xxviper@umich.edu (Chris Herringshaw) wrote:
- >
- >Just wondering if anyone has found a fairly decent way to pass objects
- >over network connections. Nothing extravagent in my objects, like
- >other classes, pointers, etc, but I do have one arbitrary length string.
- >This suggests that bundling the class up into a struct and using
- >RPC would not be very simple. Any ideas from the guru's?
- >
- >Thank you.
- >
-
- You arbitrary length string is it a
- char * or a class string
- Use string whenever possible, it helps with class streaming.
- I don't know if this helps, but now you could easily write
- the class to a file and send the file.
- Example:
-
- class MyClass
- {
- private:
- string lVersion, ui, ui2;
- ..
- ..
- friend ipstream & operator >> ( ipstream &is, MyClass &p );
- friend opstream & operator << ( opstream &os, const MyClass &p );
- };
-
- ipstream & operator >> ( ipstream &is, MyClass &p )
- {
- is >> p.lVersion
- >> p.ui
- >> p.ui2;
-
- return is;
- }
-
- opstream & operator << ( opstream &os, const MyClass &p )
- {
- os << p.lVersion
- << p.ui
- << p.ui2;
-
- return os;
- }
-